<html>
<head><meta charset="utf-8"><title>Stabilize const_fn_transmute, const_fn_union · t-lang · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/index.html">t-lang</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html">Stabilize const_fn_transmute, const_fn_union</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="242694729"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/242694729" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#242694729">(Jun 15 2021 at 07:01)</a>:</h4>
<p>FYI, here's a PR waiting for FCP to be started. :)<br>
<a href="https://github.com/rust-lang/rust/pull/85769">https://github.com/rust-lang/rust/pull/85769</a><br>
<a href="https://github.com/rust-lang/rust/pull/85769#issuecomment-854363720">Stabilization report</a></p>



<a name="245413979"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245413979" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245413979">(Jul 09 2021 at 08:15)</a>:</h4>
<p>FWIW I am a bit surprised that this is not being discussed a bit more</p>
<blockquote>
<p>However, this will still let us write code like</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">pub</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="k">unsafe</span><span class="w"> </span><span class="k">fn</span> <span class="nf">random</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="kt">usize</span> <span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">5</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="n">std</span>::<span class="n">mem</span>::<span class="n">transmute</span><span class="p">(</span><span class="o">&amp;</span><span class="n">a</span><span class="p">)</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>which would be the first stable const fn that is not guaranteed to behave deterministically at run-time.<br>
This function certainly has UB when called at compile-time, but whether it has UB when called at run-time <a href="https://github.com/rust-lang/unsafe-code-guidelines/issues/286">is unclear</a>.</p>
</blockquote>
<p><span class="user-group-mention" data-user-group-id="1977">@T-lang</span> y'all did see this part of the stabilization report, right?</p>



<a name="245420349"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245420349" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245420349">(Jul 09 2021 at 09:22)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> I saw it, but now that you mention it... :)</p>



<a name="245420404"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245420404" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245420404">(Jul 09 2021 at 09:23)</a>:</h4>
<p>I guess that I felt comfortable with it because I think we want to get to a place where as much of the language is <code>const fn</code> as possible</p>



<a name="245420415"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245420415" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245420415">(Jul 09 2021 at 09:23)</a>:</h4>
<p>and we already agreed that this will include some UB</p>



<a name="245420454"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245420454" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245420454">(Jul 09 2021 at 09:23)</a>:</h4>
<p>but I agree that this is a milestone worthy of discussion</p>



<a name="245470894"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245470894" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245470894">(Jul 09 2021 at 17:14)</a>:</h4>
<p>Though as <span class="user-mention" data-user-id="239881">@Josh Triplett</span> pointed out, a <em>safe</em> <code>const fn() -&gt; usize</code> would have to be const-unsound to be non-deterministic.<br>
This would still be enough to use <code>const fn</code> as a guarantee that other code can rely on.<br>
However, it would <em>not</em> be enough for the compiler to perform optimizations based on the fact that a function is <code>const fn</code> -- but that seems highly speculative anyway.</p>



<a name="245470950"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245470950" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245470950">(Jul 09 2021 at 17:14)</a>:</h4>
<p>So maybe this is no as big a milestone as I thought it is (the milestone is coming though, if we want to tackle <code>const_fn_float</code> some day^^)</p>



<a name="245471008"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245471008" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245471008">(Jul 09 2021 at 17:15)</a>:</h4>
<p>I would love for the compiler to be able to figure out when most const functions are in fact pure functions, and therefore can participate in things like CSE.</p>



<a name="245472699"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245472699" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245472699">(Jul 09 2021 at 17:29)</a>:</h4>
<p>if the compiler can "see" the function, it can analyze its body to check for this (but then it can do that for all functions, not just for <code>const fn</code>).<br>
if this is supposed to be possible even for <code>const fn</code> about which we know <em>nothing</em> except for their type... then I think this makes const heap allocations pretty much impossible.^^</p>



<a name="245491815"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245491815" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245491815">(Jul 09 2021 at 20:12)</a>:</h4>
<p>Is this just about optimization?</p>



<a name="245491826"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245491826" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245491826">(Jul 09 2021 at 20:12)</a>:</h4>
<p>Because in principle we could propagate up flags and things, too</p>



<a name="245491839"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245491839" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245491839">(Jul 09 2021 at 20:12)</a>:</h4>
<p>e.g., we analyze it within the crate and propagate a "pure" hint</p>



<a name="245491876"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245491876" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245491876">(Jul 09 2021 at 20:12)</a>:</h4>
<p>it feels nice to me that this is something we do equally for both fn and not fn</p>



<a name="245491903"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245491903" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245491903">(Jul 09 2021 at 20:13)</a>:</h4>
<p>is it still the case that nondeterminism requires unsafe <em>at some point in the stack</em>?</p>



<a name="245491913"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245491913" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245491913">(Jul 09 2021 at 20:13)</a>:</h4>
<p>presumably yes</p>



<a name="245495591"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245495591" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245495591">(Jul 09 2021 at 20:46)</a>:</h4>
<p>"yes and"</p>
<p><code>ptr as usize</code> is safe but not yet allowed in const fn, so we'd have to never allow it in const fn in the future</p>
<p>union transmutation was hoped to some day be fully safe in some cases if the fields are statically known. It can still potentially allow many safe transmutes without allowing pointer transmutes though.</p>



<a name="245536679"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245536679" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245536679">(Jul 10 2021 at 07:59)</a>:</h4>
<blockquote>
<p>ptr as usize is safe but not yet allowed in const fn</p>
</blockquote>
<p>indeed, and for this reason I don't intend to ever allow it in <code>const fn</code>... I think we can provide APIs for "the typical things people do with ptr-int-casts" that are fully deterministic and hence can be provided at const-time as well. But that's <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/Can.20we.20make.20more.20.60const.20unsafe.60.20now.3F">a separate discussion</a>.</p>



<a name="245536790"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245536790" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245536790">(Jul 10 2021 at 08:01)</a>:</h4>
<p><span class="user-mention" data-user-id="239881">@Josh Triplett</span> wrote</p>
<blockquote>
<p>I'm definitely talking about a sound analysis. Setting aside the current CTFE architecture for a moment, isn't this possible by tracking abstract pointers even when they're stored in ints, and doing symbolic evaluation on them while treating the abstract pointer value as opaque? For a first pass, this could just error out the moment you do something that depends on the value of the pointer other than the bits determined by its alignment; that alone would be enough to handle usage of the low-bits, for instance.</p>
</blockquote>
<p>I think you are misunderstanding what this analysis needs to do. When you actually <em>run</em> CTFE code, we can already reliably detect when you are doing something that would depend on the actual physical base address of a pointer, and we stop evaluation. This is insufficient.</p>



<a name="245536856"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245536856" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245536856">(Jul 10 2021 at 08:02)</a>:</h4>
<p>Going back to the example</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">pub</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="k">fn</span> <span class="nf">random</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="kt">usize</span> <span class="p">{</span><span class="w"> </span><span class="k">unsafe</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">5</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="n">std</span>::<span class="n">mem</span>::<span class="n">transmute</span><span class="p">(</span><span class="o">&amp;</span><span class="n">a</span><span class="p">)</span><span class="w"></span>
<span class="p">}}</span><span class="w"></span>
</code></pre></div>
<p>if you ever actually run this code <em>at compile-time</em>, it will error. But that does not solve the problem. The problem, as stated above, is that this</p>
<blockquote>
<p>would be the first stable const fn that is not guaranteed to <em>behave deterministically at run-time</em></p>
</blockquote>



<a name="245536943"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245536943" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245536943">(Jul 10 2021 at 08:04)</a>:</h4>
<p>basically, what you are suggesting is a <em>dynamic</em> analysis. it happens when the code is run. This "running the code" happens at compile-time as part of CTFE, but that doesn't make it any less dynamic. (When you run Python code in an interpreter, that's "dynamic". The same is true when you run Rust code in an interpreter, and that's exactly what CTFE does.)</p>



<a name="245536965"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245536965" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245536965">(Jul 10 2021 at 08:05)</a>:</h4>
<p>what we'd need to avoid the problem is a <em>static</em> analysis that <em>looks at the code without running it</em> and determines if, with any possible input, this code might ever be in the business of "leaking" information about the physical base address of a pointer. I don't think that is realistic to do.</p>



<a name="245558537"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245558537" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245558537">(Jul 10 2021 at 16:03)</a>:</h4>
<p>I understood that this analysis needed to look at runtime behavior. I was talking about doing static compile-time analysis of potential runtime behavior through symbolic evaluation.</p>
<p>I may well still be misunderstanding, of course.</p>



<a name="245559443"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245559443" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245559443">(Jul 10 2021 at 16:23)</a>:</h4>
<p>I misunderstood then, sorry.<br>
That might work for simple cases, where a lot of stuff happens in a single function, but cannot work once work is factored into multiple functions... like, you couldn't even do something like this in a <code>const fn</code></p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">unsafe</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="k">fn</span> <span class="nf">load</span><span class="p">(</span><span class="n">ptr</span>: <span class="o">*</span><span class="k">const</span><span class="w"> </span><span class="kt">usize</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kt">usize</span> <span class="p">{</span><span class="w"> </span><span class="o">*</span><span class="n">ptr</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>because another function might call this function in a way that <code>ptr</code> actually points to a pointer so we are doing a ptr-to-int transmute here.<br>
I think trying to static analyze our way out of this will not work. This is just not the kind of thing static analyses are good at. It's the kind of thing type systems are good at, but we're talking about unsafe code so that is not an option either.</p>



<a name="245589192"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245589192" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245589192">(Jul 11 2021 at 05:25)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120791">RalfJ</span> <a href="#narrow/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union/near/245536679">said</a>:</p>
<blockquote>
<blockquote>
<p>ptr as usize is safe but not yet allowed in const fn</p>
</blockquote>
<p>indeed, and for this reason I don't intend to ever allow it in <code>const fn</code>... I think we can provide APIs for "the typical things people do with ptr-int-casts" that are fully deterministic and hence can be provided at const-time as well. But that's <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/Can.20we.20make.20more.20.60const.20unsafe.60.20now.3F">a separate discussion</a>.</p>
</blockquote>
<p>It seems highly likely if <code>ptr as usize</code> is forbidden from const fn, but <code>transmute</code>ing ptr -&gt; usize and vice versa isn't, people will do the latter. we already saw this when ptr deref is disallowed, where we got <code>transmute</code> of raw ptr to reference (in const/static initializers, not const fn).</p>
<p>the difference being is that it looks like transmute integer -&gt; ptr is <em>always</em> UB, according to <a href="https://github.com/rust-lang/unsafe-code-guidelines/issues/286">https://github.com/rust-lang/unsafe-code-guidelines/issues/286</a></p>



<a name="245603558"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245603558" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245603558">(Jul 11 2021 at 11:58)</a>:</h4>
<blockquote>
<p>It seems highly likely if ptr as usize is forbidden from const fn, but transmuteing ptr -&gt; usize and vice versa isn't, people will do the latter.</p>
</blockquote>
<p>Yes I am aware. I don't really know a way to avoid this though. ptr-to-int casts <em>cannot</em> be a safe operation in CTFE, and I feel like allowing them only unsafely with a very bespoke set of rules sets us up for even more surprises than disallowing them outright. <a href="https://github.com/rust-lang/rust/issues/87020">#87020</a> adds a very explicit note about this in the error saying that you cannot cast a ptr to an int:</p>
<div class="codehilite"><pre><span></span><code>   = note: at compile-time, pointers do not have an integer value
   = note: avoiding this restriction via `transmute`, `union`, or raw pointers leads to compile-time undefined behavior
</code></pre></div>
<p>I think teaching people is the best we can do here. if you have any further suggestions for how we could teach them, I am all ears. :)<br>
note that rustc is pretty good at catching you when you try to still do these transmutes despite all these warnings.</p>



<a name="245603582"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245603582" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245603582">(Jul 11 2021 at 11:59)</a>:</h4>
<blockquote>
<p>the difference being is that it looks like transmute integer -&gt; ptr is always UB, according to <a href="https://github.com/rust-lang/unsafe-code-guidelines/issues/286">https://github.com/rust-lang/unsafe-code-guidelines/issues/286</a></p>
</blockquote>
<p>yeah and then there's that, which is a mostly unresolved discussion since we don't yet know how LLVM will resolve this problem^^ (and that's hoping they resolve it at all...)</p>



<a name="245625217"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245625217" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245625217">(Jul 11 2021 at 20:35)</a>:</h4>
<blockquote>
<p>= note: at compile-time, pointers do not have an integer value<br>
= note: avoiding this restriction via <code>transmute</code>, <code>union</code>, or raw pointers leads to compile-time undefined behavior</p>
</blockquote>
<p>this is good, but I think a similar message should be emitted on direct transmutes as well. I'm aware we can't catch every case, but catching the likely to happen ones would probably help a lot.</p>



<a name="245650831"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245650831" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245650831">(Jul 12 2021 at 06:53)</a>:</h4>
<p>transmute with a target type of pointer or array of pointers should warn, yeah</p>



<a name="245674128"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245674128" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245674128">(Jul 12 2021 at 11:36)</a>:</h4>
<p>You mean like a targeted lint or so?</p>



<a name="245708776"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245708776" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245708776">(Jul 12 2021 at 16:10)</a>:</h4>
<p>yeah, and it doesn't have to be perfect but any warning is probably better than none</p>



<a name="245710624"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245710624" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245710624">(Jul 12 2021 at 16:20)</a>:</h4>
<p>sure, that does not seem unreasonable</p>



<a name="245720492"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245720492" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Pratt <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245720492">(Jul 12 2021 at 17:39)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span>  With regard to the link you mentioned in <a href="https://github.com/rust-lang/rust/issues/85769">#85769</a>, such a lint already exists, correct? You would just like to see something a bit more detailed?</p>



<a name="245721320"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245721320" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245721320">(Jul 12 2021 at 17:45)</a>:</h4>
<p>I don't think such a lint exists</p>



<a name="245721389"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245721389" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245721389">(Jul 12 2021 at 17:46)</a>:</h4>
<p>we have other transmute lints I think? Or am I thinking about clippy?</p>



<a name="245722049"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245722049" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Pratt <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245722049">(Jul 12 2021 at 17:51)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="cp">#![feature(const_fn_transmute)]</span><span class="w"></span>

<span class="k">use</span><span class="w"> </span><span class="n">std</span>::<span class="n">mem</span>::<span class="n">transmute</span><span class="p">;</span><span class="w"></span>

<span class="k">const</span><span class="w"> </span><span class="k">fn</span> <span class="nf">x</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="kt">usize</span> <span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">s</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;</span><span class="s">""</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="k">unsafe</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">transmute</span><span class="p">(</span><span class="n">s</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="o">*</span><span class="k">const</span><span class="w"> </span><span class="n">_</span><span class="p">)</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">const</span><span class="w"> </span><span class="n">X</span>: <span class="kt">usize</span> <span class="o">=</span><span class="w"> </span><span class="n">x</span><span class="p">();</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>Is this not what you're referring to? This currently errors with <code>error[E0080]: it is undefined behavior to use this value</code>.</p>



<a name="245722447"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245722447" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245722447">(Jul 12 2021 at 17:53)</a>:</h4>
<p>yeah but that's not a lint</p>



<a name="245722463"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245722463" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245722463">(Jul 12 2021 at 17:53)</a>:</h4>
<p>that's a dynamic check during CTFE</p>



<a name="245722491"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245722491" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245722491">(Jul 12 2021 at 17:53)</a>:</h4>
<p>a lint would be a static check before CTFE even starts</p>



<a name="245722567"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245722567" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245722567">(Jul 12 2021 at 17:54)</a>:</h4>
<p>it would error on</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">pub</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="k">fn</span> <span class="nf">x</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="kt">usize</span> <span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">s</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;</span><span class="s">""</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="k">unsafe</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">transmute</span><span class="p">(</span><span class="n">s</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="o">*</span><span class="k">const</span><span class="w"> </span><span class="n">_</span><span class="p">)</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>even if this crate never calls that fn inside a  <code>const</code></p>



<a name="245722699"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245722699" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Pratt <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245722699">(Jul 12 2021 at 17:55)</a>:</h4>
<p>Ahh I see. You'd like to reject (or warn?) the transmute itself.</p>



<a name="245722771"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245722771" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Pratt <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245722771">(Jul 12 2021 at 17:55)</a>:</h4>
<p>I'll be honest — I've never implemented a lint and have near zero idea on how they're done. I'll check the dev guide, but got any pointers in the right direction?</p>



<a name="245723027"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245723027" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245723027">(Jul 12 2021 at 17:57)</a>:</h4>
<p>you could check what existing lints to, e.g. <a href="https://github.com/rust-lang/rust/blob/3a24abd22fd25c836d8b4d75ff46c833f9c3934c/compiler/rustc_lint/src/builtin.rs#L2414">https://github.com/rust-lang/rust/blob/3a24abd22fd25c836d8b4d75ff46c833f9c3934c/compiler/rustc_lint/src/builtin.rs#L2414</a></p>



<a name="245723126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245723126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245723126">(Jul 12 2021 at 17:58)</a>:</h4>
<p>that one actually also needs to look for <code>transmute</code> to it's probably a good template :)</p>



<a name="245723219"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245723219" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Pratt <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245723219">(Jul 12 2021 at 17:59)</a>:</h4>
<p>I'll take a look. <code>rustc_lint</code> is aware of types I presume? Otherwise this would be quite difficult.</p>



<a name="245723465"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245723465" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245723465">(Jul 12 2021 at 18:00)</a>:</h4>
<p>yes, it works on HIR which is fully typed</p>



<a name="245723548"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245723548" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Pratt <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245723548">(Jul 12 2021 at 18:01)</a>:</h4>
<p>Awesome. I'll look at implementing a lint later today.</p>



<a name="245723996"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245723996" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245723996">(Jul 12 2021 at 18:04)</a>:</h4>
<p>Great. :) Feel free to ask if you need any help!</p>



<a name="245724031"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245724031" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245724031">(Jul 12 2021 at 18:05)</a>:</h4>
<p>(I might not be super responsive, but if you ask on Zulip there's always more people that can help :)</p>



<a name="245724094"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245724094" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245724094">(Jul 12 2021 at 18:05)</a>:</h4>
<p>however probably best to open a new zulip topic for this, since the implementation details of the lint do not really pertain to the stabilization discussion</p>



<a name="245724429"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245724429" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Pratt <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245724429">(Jul 12 2021 at 18:07)</a>:</h4>
<p>Sounds good.</p>



<a name="245808649"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245808649" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245808649">(Jul 13 2021 at 11:09)</a>:</h4>
<p>Note that there definitely is a clippy lint</p>



<a name="245808663"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245808663" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245808663">(Jul 13 2021 at 11:09)</a>:</h4>
<p>you may want to use it as inspiration</p>



<a name="245889996"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245889996" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Pratt <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245889996">(Jul 13 2021 at 21:14)</a>:</h4>
<p>Lint should be warn or deny by default?</p>



<a name="245896067"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245896067" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245896067">(Jul 13 2021 at 22:09)</a>:</h4>
<p>/me personally would think "deny".</p>



<a name="245896085"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245896085" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245896085">(Jul 13 2021 at 22:09)</a>:</h4>
<p>(Or, ideally, something that can't be turned off.)</p>



<a name="245896132"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245896132" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245896132">(Jul 13 2021 at 22:10)</a>:</h4>
<p>(That would draw a line so we can decide about such handling later.)</p>



<a name="245896158"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245896158" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Pratt <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245896158">(Jul 13 2021 at 22:10)</a>:</h4>
<p>I tried "forbid" but it wouldn't let me. Dunno if that's just because it's a lint and not a proper error.</p>



<a name="245896227"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245896227" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245896227">(Jul 13 2021 at 22:11)</a>:</h4>
<p>I'm not sure you can have a forbid-by-default lint.</p>



<a name="245896234"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245896234" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245896234">(Jul 13 2021 at 22:11)</a>:</h4>
<p>That'd be a nice way to handle hard-errors.</p>



<a name="245896263"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245896263" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Pratt <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245896263">(Jul 13 2021 at 22:11)</a>:</h4>
<p>Like I said I tried at first but the compiler complained. Presumably that restriction would be possible to lift if desired, though.</p>



<a name="245927678"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245927678" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245927678">(Jul 14 2021 at 07:27)</a>:</h4>
<p>that's strange, I thought I used forbid-by-default lints for crater runs in the past... but maybe this is a more recent change</p>



<a name="245927895"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245927895" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Pratt <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245927895">(Jul 14 2021 at 07:30)</a>:</h4>
<p>I wouldn't know. It seems like an odd restriction, as forbid-by-default has its purposes (like right here!)</p>



<a name="245930322"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245930322" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245930322">(Jul 14 2021 at 08:01)</a>:</h4>
<p>OTOH I think deny-by-default is strong enough</p>



<a name="245930335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245930335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245930335">(Jul 14 2021 at 08:01)</a>:</h4>
<p>it's also what we do for the invalid_values lint, for example</p>



<a name="245930840"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245930840" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Pratt <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245930840">(Jul 14 2021 at 08:08)</a>:</h4>
<p>I'm assuming you mean the overflowing_literals, but I honestly find it odd that that's not forbidden. There is no _possible_ way that that's what's intended in the same way that there's no way to do this soundly.</p>



<a name="245930912"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245930912" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Pratt <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245930912">(Jul 14 2021 at 08:08)</a>:</h4>
<p>To be clear I'm fine with deny by default here, I would just strongly prefer forbid.</p>



<a name="245934825"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245934825" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245934825">(Jul 14 2021 at 09:01)</a>:</h4>
<p>no I mean invalid_values</p>



<a name="245934994"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245934994" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245934994">(Jul 14 2021 at 09:02)</a>:</h4>
<p>oh, invalid_value. looks like I failed to properly use plural...<br>
added in <a href="https://github.com/rust-lang/rust/pull/63346">https://github.com/rust-lang/rust/pull/63346</a></p>



<a name="245974121"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245974121" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Pratt <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245974121">(Jul 14 2021 at 15:15)</a>:</h4>
<p>Well the rest of my message is still relevant.</p>



<a name="245974144"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/245974144" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Pratt <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#245974144">(Jul 14 2021 at 15:15)</a>:</h4>
<p>And for this there's no back compatibility concern</p>



<a name="246325307"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246325307" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246325307">(Jul 17 2021 at 13:36)</a>:</h4>
<p>it's similar to <code>invalid_value</code> in the sense that both are about UB</p>



<a name="246325310"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246325310" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246325310">(Jul 17 2021 at 13:36)</a>:</h4>
<p>so by the same argument we should make <code>invalid_value</code> forbid-by-default, i.e., a hard error</p>



<a name="246325318"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246325318" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246325318">(Jul 17 2021 at 13:36)</a>:</h4>
<p>I'm not fundamentally disagreeing with your argument, I am just pointing out that deny-by-default is consistent here. :)</p>



<a name="246325328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246325328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246325328">(Jul 17 2021 at 13:37)</a>:</h4>
<p>personally I dont have a terribly strong opinion on deny vs forbid here</p>



<a name="246426749"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246426749" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246426749">(Jul 19 2021 at 08:05)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> so I saw <span class="user-mention" data-user-id="384014">@Patrick Walton</span>'s tweet here:</p>
<p><a href="https://twitter.com/pcwalton/status/1417023289893953536">https://twitter.com/pcwalton/status/1417023289893953536</a></p>
<div class="inline-preview-twitter"><div class="twitter-tweet"><a href="https://twitter.com/pcwalton/status/1417023289893953536"><img class="twitter-avatar" src="https://uploads.zulipusercontent.net/106ebf871f7e16a9c776d347794ede671c46a992/68747470733a2f2f7062732e7477696d672e636f6d2f70726f66696c655f696d616765732f3631393038383731382f747769747465722d69636f6e5f6e6f726d616c2e6a706567"></a><p>Why is "const fn" so tricky to implement in Rust? Because it absolutely must be deterministic: identical inputs must *always* produce identical outputs. Otherwise the compiler could think two arrays have equal length when they don't, breaking memory safety.</p><span>- Patrick Walton (@pcwalton)</span></div></div><p>which raises an interesting point that I don't think has come up in this discussion. That is, determinism isn't just about things like <em>CSE</em>, of course, it's also about "when can we decide that two consts are equal". I'm beginning to have mild second thoughts about moving forward here until we've squared away the "equality story", especially around const generics, where we are likely to have incomplete knowledge of the const expression in question.</p>



<a name="246426827"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246426827" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246426827">(Jul 19 2021 at 08:06)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> the equality story is basically the valtree story</p>



<a name="246426837"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246426837" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246426837">(Jul 19 2021 at 08:06)</a>:</h4>
<p>I know</p>



<a name="246426843"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246426843" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246426843">(Jul 19 2021 at 08:06)</a>:</h4>
<p>I don't see how that is changed by transmute and union <em>in <code>const fn</code></em></p>



<a name="246426851"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246426851" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246426851">(Jul 19 2021 at 08:06)</a>:</h4>
<p>we already allow transmute and union in <code>const</code>/<code>static</code></p>



<a name="246426932"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246426932" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246426932">(Jul 19 2021 at 08:07)</a>:</h4>
<p>Hmm. The question I am trying to answer is, how much do we have to be able to evaluate a <code>const fn</code> before we can determine that its <em>output</em> will be equal?</p>



<a name="246426947"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246426947" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246426947">(Jul 19 2021 at 08:07)</a>:</h4>
<p>Also, is part of the "safety burden" of a const fn that its output is deterministic?</p>



<a name="246426950"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246426950" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246426950">(Jul 19 2021 at 08:07)</a>:</h4>
<p>I think I disagree with <span class="user-mention" data-user-id="384014">@Patrick Walton</span> here -- determinism <em>of CTFE evaluation</em> is not a limiting factor. Even Miri is fully deterministic in its default settings!</p>



<a name="246427010"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246427010" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246427010">(Jul 19 2021 at 08:08)</a>:</h4>
<p>so <code>-Zunleash-the-miri-inside-of-you</code> does not break determinism</p>



<a name="246427051"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246427051" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246427051">(Jul 19 2021 at 08:09)</a>:</h4>
<p>what makes extending CTFE so hard is our strong safety guarantees</p>



<a name="246427075"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246427075" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246427075">(Jul 19 2021 at 08:09)</a>:</h4>
<p>if we were okay with checking things "when the const gets evaluated" (post-monomorphization errors), things would be <em>a lot</em> easier</p>



<a name="246427210"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246427210" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246427210">(Jul 19 2021 at 08:11)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union/near/246426947">said</a>:</p>
<blockquote>
<p>Also, is part of the "safety burden" of a const fn that its output is deterministic?</p>
</blockquote>
<p>there are two similar but very distinct questions here:</p>
<ul>
<li>is compile-time evaluation deterministic? that is typically rather easy to ensure. (we recently had trouble here with a PR that turned OOM ICEs into nicer errors since that can introduce non-determinism, but I think this is the first time we had such trouble.)</li>
<li>is "calling a <code>const fn</code>" <em>at runtime</em> deterministic?</li>
</ul>



<a name="246427232"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246427232" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246427232">(Jul 19 2021 at 08:11)</a>:</h4>
<p>I think there is a third question</p>



<a name="246427300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246427300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246427300">(Jul 19 2021 at 08:12)</a>:</h4>
<p>Well, maybe there isn't :) I'm trying to phrase it</p>



<a name="246427306"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246427306" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246427306">(Jul 19 2021 at 08:12)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union/near/246426932">said</a>:</p>
<blockquote>
<p>Hmm. The question I am trying to answer is, how much do we have to be able to evaluate a <code>const fn</code> before we can determine that its <em>output</em> will be equal?</p>
</blockquote>
<p>so I dont know all the plans here, but so far the equality story only concerns the final value that comes out of evaluation, right? <code>const fn</code> is irrelevant for that.</p>



<a name="246427317"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246427317" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246427317">(Jul 19 2021 at 08:12)</a>:</h4>
<p>this is kind of the point I am raising</p>



<a name="246427333"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246427333" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246427333">(Jul 19 2021 at 08:12)</a>:</h4>
<p>are there plans for reasoning like "<code>a == b</code> and hence <code>f(a) == f(b)</code>"?</p>



<a name="246427334"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246427334" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246427334">(Jul 19 2021 at 08:12)</a>:</h4>
<p>I'm not sure I like that, but it may be too late to change it</p>



<a name="246427363"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246427363" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246427363">(Jul 19 2021 at 08:13)</a>:</h4>
<p>I mean, if you consider something like</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">A</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="p">(</span><span class="n">x</span>: <span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="p">{</span><span class="n">A</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="p">}])</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="o">..</span><span class="p">.</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="246427383"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246427383" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246427383">(Jul 19 2021 at 08:13)</a>:</h4>
<p>(or whatever syntax we use there)</p>



<a name="246427434"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246427434" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246427434">(Jul 19 2021 at 08:14)</a>:</h4>
<p>you definitely need the ability to think about whether <code>(A + 1) == (A + 1)</code>, right?</p>



<a name="246427472"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246427472" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246427472">(Jul 19 2021 at 08:14)</a>:</h4>
<p>I don't think we can do such reasoning for all types (if <code>a</code>, <code>b</code> are mutable references there are side-effects here that make such equational reasoning... dubious), but if e.g. <code>a</code>, <code>b</code> are of integer type then I think this is easily given with all the extensions we are currently considering</p>



<a name="246427484"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246427484" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246427484">(Jul 19 2021 at 08:14)</a>:</h4>
<p>since it is again a <em>compile-time</em> evaluation property</p>



<a name="246427496"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246427496" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246427496">(Jul 19 2021 at 08:15)</a>:</h4>
<p>well, if they come out from a <code>const fn</code>...</p>



<a name="246427502"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246427502" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246427502">(Jul 19 2021 at 08:15)</a>:</h4>
<p>and there is no non-determinism that could possibly make <code>f(4)</code> different from <code>f(4)</code></p>



<a name="246427530"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246427530" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246427530">(Jul 19 2021 at 08:15)</a>:</h4>
<p>...right, this is what I was thinking. Instead what we have to worry about is that <code>f(4)</code> might <em>result in a value that isn't an actual usize</em></p>



<a name="246427531"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246427531" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246427531">(Jul 19 2021 at 08:15)</a>:</h4>
<p>the only hard question is "what happens when you run a <code>const fn</code> at runtime", which is irrelevant for this "congruence" property -- so congruence is 'easy'</p>



<a name="246427538"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246427538" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246427538">(Jul 19 2021 at 08:15)</a>:</h4>
<p>(that the compiler can "use')</p>



<a name="246427544"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246427544" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246427544">(Jul 19 2021 at 08:15)</a>:</h4>
<p>e.g., a transmute from a pointer</p>



<a name="246427556"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246427556" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246427556">(Jul 19 2021 at 08:15)</a>:</h4>
<p>yeah but we'd catch that during valtree construcion</p>



<a name="246427598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246427598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246427598">(Jul 19 2021 at 08:16)</a>:</h4>
<p>well we already catch it during const validation</p>



<a name="246427601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246427601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246427601">(Jul 19 2021 at 08:16)</a>:</h4>
<p>right. at monomorphization time.</p>



<a name="246427604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246427604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246427604">(Jul 19 2021 at 08:16)</a>:</h4>
<p>well, this is the whole "evaluatable" debate</p>



<a name="246427616"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246427616" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246427616">(Jul 19 2021 at 08:16)</a>:</h4>
<p>in any case, good, I am satisfied.</p>



<a name="246427617"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246427617" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246427617">(Jul 19 2021 at 08:16)</a>:</h4>
<p>compile-time UB is only caught at monomorphization time, yes</p>



<a name="246427626"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246427626" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246427626">(Jul 19 2021 at 08:16)</a>:</h4>
<p>not really much of a way around that I think, but I don't think it's a problem</p>



<a name="246427642"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246427642" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246427642">(Jul 19 2021 at 08:17)</a>:</h4>
<p>we really need to have a good "overall design doc" here</p>



<a name="246427650"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246427650" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246427650">(Jul 19 2021 at 08:17)</a>:</h4>
<p>to capture these sorts of points</p>



<a name="246427664"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246427664" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246427664">(Jul 19 2021 at 08:17)</a>:</h4>
<p>I am thinking about what form I think that should take</p>



<a name="246427675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246427675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246427675">(Jul 19 2021 at 08:17)</a>:</h4>
<p>for just const-eval we have <a href="https://github.com/rust-lang/const-eval/">https://github.com/rust-lang/const-eval/</a></p>



<a name="246427686"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246427686" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246427686">(Jul 19 2021 at 08:17)</a>:</h4>
<p>we don't have much for the interaction with const generics since I am not deeply familiar with const generics</p>



<a name="246427749"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246427749" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246427749">(Jul 19 2021 at 08:18)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120791">RalfJ</span> <a href="#narrow/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union/near/246427675">said</a>:</p>
<blockquote>
<p>for just const-eval we have <a href="https://github.com/rust-lang/const-eval/">https://github.com/rust-lang/const-eval/</a></p>
</blockquote>
<p>it may just be that I need to sit down read this more deeply :)</p>



<a name="246427758"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246427758" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246427758">(Jul 19 2021 at 08:18)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120791">RalfJ</span> <a href="#narrow/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union/near/246427686">said</a>:</p>
<blockquote>
<p>we don't have much for the interaction with const generics since I am not deeply familiar with const generics</p>
</blockquote>
<p>ok; this strikes me as an important part of the equation too</p>



<a name="246427796"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246427796" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246427796">(Jul 19 2021 at 08:19)</a>:</h4>
<p>We were working on a "const generics vision doc", in my view, const-eval + const-generics are (for users) kind of "one feature". I'd like to pursue that with you and <span class="user-mention" data-user-id="124288">@oli</span>, but not this minute. :)</p>



<a name="246427823"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246427823" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246427823">(Jul 19 2021 at 08:19)</a>:</h4>
<p>Thanks for clarifying things with me!</p>



<a name="246427944"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246427944" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246427944">(Jul 19 2021 at 08:21)</a>:</h4>
<p>yeah I didnt/dont really have the capacity to be closely enough involved with const generics</p>



<a name="246427972"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246427972" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246427972">(Jul 19 2021 at 08:21)</a>:</h4>
<p>I was hoping valtrees could be a nice interface between the const-eval world and the const-generic world -- the way I envision them, nothing can really go wrong any more once you have a valtree :D</p>



<a name="246428036"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stabilize%20const_fn_transmute%2C%20const_fn_union/near/246428036" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stabilize.20const_fn_transmute.2C.20const_fn_union.html#246428036">(Jul 19 2021 at 08:22)</a>:</h4>
<p>but this congruence reasoning throws a wrench into that plan...</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>